/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.web.service.support.storage.mgt;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * 存储
 *
 * @author vacoor
 */
public interface StorageManager {

    /**
     * 给定路径是否存在
     *
     * @param path
     * @return
     */
    boolean exists(String path);

    /**
     * 读取给定路径文件到给定输出流
     *
     * @param path     文件路径
     * @param out      输出流
     * @param closeOut 是否关闭输出流
     */
    boolean readTo(String path, OutputStream out, boolean closeOut) throws IOException;

//    InputStream readAsStream(String path);

//    File readAsFile(String path);

    /**
     * 存储给定流到给定路径
     *
     * @param in   要存储的输入流
     * @param path 存储路径
     * @throws IOException
     */
    void store(InputStream in, String path) throws IOException;

    /**
     * 存储给定文件到给定路径
     *
     * @param file
     * @param path
     * @throws IOException
     */
    void store(File file, String path) throws IOException;

    void mkdirs(String path);

    /**
     * 关闭 [当前线程上下文资源]
     */
    void close();

}
